{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单管理 - 智淘go商城</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        /* 基础样式重置 */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
            background: url('https://pic2.zhimg.com/v2-86ffa1ad12c00587d5cb6f9bd362578a_r.jpg?source=1940ef5c') no-repeat center center fixed;
            color: #333;
            line-height: 1.6;
        }

        /* 容器布局 */
        .container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 0 1.5rem;
        }

        /* 标题区 */
        .header {
            background: linear-gradient(135deg, #ff6700, #ff8f00);
            color: white;
            padding: 2rem 0;
            border-radius: 12px 12px 0 0;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }

        .header h1 {
            font-weight: 600;
            font-size: 2rem;
            text-align: center;
        }

        /* 订单卡片 */
        .order-card {
            background: white;
            border-radius: 12px;
            margin: 1.5rem 0;
            box-shadow: 0 2px 8px rgba(0,0,0,0.08);
            transition: transform 0.2s, box-shadow 0.2s;
            overflow: hidden;
        }

        .order-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 16px rgba(0,0,0,0.12);
        }

        /* 订单概览 */
        .order-overview {
            padding: 1.5rem;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #fcfcfc;
        }

        .order-meta {
            flex: 1;
        }

        .order-number {
            font-size: 1.2rem;
            font-weight: 600;
            color: #333;
            margin-bottom: 0.5rem;
        }

        .order-status {
            display: inline-flex;
            align-items: center;
            padding: 0.3rem 0.8rem;
            border-radius: 20px;
            font-size: 0.9rem;
            font-weight: 500;
        }

        .status-pending { background: #fff3cd; color: #856404; }
        .status-paid { background: #d4edda; color: #155724; }
        .status-shipped { background: #d1ecf1; color: #0c5460; }
        .status-completed { background: #e2e3e5; color: #383d41; }

        /* 商品项 */
        .order-items {
            padding: 1.5rem;
        }

        .product-item {
            display: flex;
            align-items: center;
            padding: 1rem;
            margin: 0.5rem 0;
            background: #fff;
            border-radius: 8px;
            transition: background 0.2s;
        }

        .product-item:hover {
            background: #f8f9fa;
        }

        .product-image {
            width: 80px;
            height: 80px;
            border-radius: 6px;
            overflow: hidden;
            margin-right: 1.5rem;
            flex-shrink: 0;
        }

        .product-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s;
        }

        .product-item:hover img {
            transform: scale(1.05);
        }

        .product-info {
            flex: 1;
        }

        .product-name {
            font-weight: 500;
            margin-bottom: 0.3rem;
        }

        .product-description {
            font-size: 0.9rem;
            color: #666;
            margin: 0.5rem 0;
            line-height: 1.4;
        }

        .product-specs {
            display: flex;
            gap: 1.5rem;
            color: #666;
            font-size: 0.9rem;
        }

        .price-tag {
            font-weight: 600;
            color: #e74c3c;
            min-width: 100px;
            text-align: right;
        }

        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 4rem 0;
            color: #666;
        }

        .empty-state i {
            font-size: 3rem;
            color: #ddd;
            margin-bottom: 1rem;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .container {
                padding: 0 1rem;
            }

            .order-overview {
                flex-direction: column;
                align-items: flex-start;
                gap: 1rem;
            }

            .product-item {
                flex-direction: column;
                align-items: flex-start;
            }

            .product-image {
                margin-right: 0;
                margin-bottom: 1rem;
            }

            .price-tag {
                text-align: left;
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1><i class="fas fa-clipboard-list"></i> 我的订单</h1>
        </div>

        <div class="order-list">
            {% if order_details %}
                {% for detail in order_details %}
                    <div class="order-card">
                        <div class="order-overview">
                            <div class="order-meta">
                                <div class="order-number">订单号：{{ detail.order.order_number }}</div>
                                <div class="order-time">下单时间：{{ detail.order.created_at|date:"Y-m-d H:i" }}</div>
                            </div>
                            <div class="order-total">
                                <div class="total-amount">总金额：¥{{ detail.order.total_price }}</div>
                                <span class="order-status status-{{ detail.order.status }}">
                                    {{ detail.order.get_status_display }}
                                </span>
                            </div>
                        </div>

                        <div class="order-items">
                            {% for item in detail.items %}
                                <div class="product-item">
                                    <div class="product-image">
                                        <img src="{{ item.product_image }}" alt="{{ item.product_name }}">
                                    </div>
                                    <div class="product-info">
                                        <div class="product-name">{{ item.product_name }}</div>
                                        <!-- 新增：商品描述 -->
                                        <div class="product-description">
                                            {{ item.product_description }}
                                        </div>
                                        <div class="product-specs">
                                            <span>单价：¥{{ item.unit_price }}</span>
                                            <span>数量：{{ item.quantity }}</span>
                                        </div>
                                    </div>
                                    <div class="price-tag">
                                        ¥{{ item.unit_price|floatformat:2 }}
                                    </div>
                                </div>
                            {% endfor %}
                        </div>
                    </div>
                {% endfor %}
            {% else %}
                <div class="empty-state">
                    <i class="fas fa-box-open"></i>
                    <p>您还没有任何订单记录</p>
                </div>
            {% endif %}
        </div>
    </div>
</body>
</html>